package com.akcome.apollo.controller;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.RequestMapping;

import com.akcome.apollo.common.ApolloConstants;
import com.akcome.apollo.domain.BmpAccount;
import com.akcome.apollo.service.BmpAccountService;

/**
 * 移动端
 * @author wn
 *
 */
@Controller
@RequestMapping("/mobile")
public class MobileController {

	@Autowired
	private BmpAccountService bmpAccountService;
	
	/**
	 * 登录
	 * @return
	 */
	@RequestMapping("/login")
	public String login(){
		
		return "mobile/login";
	}
	
	/**
	 * 个人中心
	 * @return
	 */
	@RequestMapping("/home")
	public String home(@CookieValue(required = false,value=ApolloConstants.COOKIE_ACCOUNT) Long c_accountId,  ModelMap modelMap,HttpServletResponse response){
		bmpAccountService.homeSetting(modelMap,c_accountId,response);
		bmpAccountService.homeUserSetting(modelMap);
		return "mobile/home";
	}
	
	/**
	 * 收益记录
	 * @param c_accountId
	 * @return
	 */
	@RequestMapping("/home/income")
	public String income(@CookieValue(required = false,value=ApolloConstants.COOKIE_ACCOUNT) Long c_accountId,ModelMap modelMap){
		BmpAccount bmpAccount = bmpAccountService.findOne(c_accountId);
		modelMap.put("bmpAccount", bmpAccount);
		return "mobile/income";
	}
}
